const express = require("express");
const router = express.Router();
const db = require("../db/index");

router.get("/get", function (req, res) {
  const mobiles = db.mobiles.get("mobiles").value() || [];
  return res.json({
    code: 0,
    data: mobiles || [],
  });
});
router.post("/add", function (req, res) {
  const { mobile } = req.body;
  db.mobiles
    .get("mobiles")
    .push({
      mobile,
    })
    .write();
  return res.json({
    code: 0,
    data: [],
  });
});
module.exports = router;
